package HUZ;

import java.util.Locale;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }

    public static void main1(String[] args) {

    }

    public static Node copyRandomList(Node head) {
        if(head==null)return null;
        TreeMap<Node,Node> map=new TreeMap<>();
        Node cur=head;
        while(cur!=null){
            Node clone=new Node(cur.val);
            //将每一个旧节点和新节点进行映射
            map.put(cur,clone);
            cur=cur.next;
        }
        //开始拷贝
        Node h1=head,h2=head.next;
        Node clone2=null,cloneNext=null;
        while(cur!=null){
            clone2=map.get(cur);
            cloneNext=map.get(cur.next);
            clone2.random=cloneNext;
            cur=cur.next;
        }

        return map.get(head);
    }


public static boolean isChar(Character a){

        if((a>='a'&&a<='z')||(a>='A'&&a<='Z')){
            return true;
        }
        return false;
}




}